 $(function(){
 	
 	    $(".edita").click(function(){
 	        //获取当前点击
 			
 	           trobj= $(this).parents('tr');
 	           uid = trobj.find("td:eq(0)").text()
 			   uimgtd = trobj.find("td:eq(1)")
 	           uname = trobj.find("td:eq(2)").text()
			   // passwordtd = trobj.find("td:eq(3)")
			   // password = passwordtd.find("input:eq(0)").val()
 	           liveaddress = trobj.find("td:eq(4)").text()
 	          address= trobj.find("td:eq(5)").text()
 	           career = trobj.find("td:eq(6)").text()
 	           tel = trobj.find("td:eq(7)").text()
			   usermsg = trobj.find("td:eq(8)").text()
 			  //  console.log(uid)
			   // console.log(uname)
 			 
 			   
 			  
 			   
 			
 			var uimg = uimgtd.find('img')
 			var uimg_copy=uimg.clone()
 			// uimg_copy.css('width','45%')
 			uimg_copy.addClass('replaceimg') //添加class类名
 			var imgshow = $('#imgContaineru2').find('img')
 			  imgshow.replaceWith(uimg_copy)
 			   $('#imgContaineru2').css('display','block')
 		
 	           $('#uidu').val(uid)
 	           $('#unameu').val(uname)
 	           // $('#passwordu').val(password)
 	           $('#liveaddressu').val(liveaddress)
 	           $('#addressu').val(address)
 	           $('#careeru').val(career)
 			   $('#telu').val(tel)
 			   $('#usermsgu').val(usermsg)
 			   show_update_img()
 	    })
 		
 	
 	                $("#submitbut2").click(function(){
 	                        $("#modbut").click()
 	                });
 								
 	})
 	 
 	
 /* 更换宠物图片 */	
 	var fileInput = document.getElementById('userimgu');
 	
 	  function showImgu(obj) {
 	    var files = obj.files
 	    document.getElementById("imgContaineru").innerHTML = getImgsByUrlu(files)
 	  }
 		 //获取图像元素
 	  function getImgsByUrlu(files) {
 	    var elements = ''
 		
 	    for (var i = 0; i < files.length; i++) {
 	      var url = window.URL.createObjectURL(files[i])
 	      elements += "<img src='" + url + "' style='width: 55%;' class='changeimg'/>"
 	    }
 	    return elements
 	  }
 		//清除修改图片
 					 function clearupdate(){
 						 var addimg = document.getElementsByClassName('changeimg')
 						 $('#imgContaineru2').css('display','none')
 						 try{
 							 addimg.item(addimg).remove()
 							
 						 }catch(err){ 
 							 console.log()
 						 }
 						 try{ fileInput.value = null;  }
						 catch(err){}
 					 
 	                                 }
 //展示添加和更新图片
 	function show_update_img(){
 		 // var imgreplace= document.getElementById('imgreplace')
 		var myModal2 = document.getElementById('myModal2')
 			
 		$('.btn-file').click( function(){
 			const eventshow = myModal2.addEventListener('mousemove',(event)=>{
 				try{    var changeimg= document.getElementsByClassName('changeimg')
 				      flagchange =  changeimg[0].TEXT_NODE
 						  // alert(changeimg)
 						  if(flagchange == 3){$('#imgContaineru2').css('display','none')}
 						  else{
 							  $('#imgContaineru2').css('display','block')
 						  }
 								 }catch(err){
 								console.log()
 							}	
 			})//mousemove
 		})//click   
 	} //show_update_img()结束
 
 
 
 function showDropdown() {  
				  
                  var dropdown = document.querySelector('.dropshowdown'); 
				   //获取修改增加后的提示信息
				  try{ 
					  var flagmy = document.getElementById('showdownbox').value;
				  }catch(err){}
				
				 var res_arg = document.getElementById('res_arg').value;
			   
				if(res_arg == '删除成功!'){
					dropdown.style.display = 'block';
						setTimeout(() => {  
						    dropdown.style.display = 'none';  
							res_arg.value =null
						}, 2000); 	
				}
				
				switch(flagmy){
				 case('用户添加成功!'):
					 dropdown.style.display = 'block';
					 	setTimeout(() => {  
					 	    dropdown.style.display = 'none';  
					 		flagmy.value =null
					 	}, 2000); 
				 case('用户添加失败!可能为用户名重复'):	
				     dropdown.style.display = 'block';
				     	setTimeout(() => {  
				     	    dropdown.style.display = 'none';  
							flagmy.value =null
				     	}, 2000); 
				case('用户信息修改成功!'):
				    dropdown.style.display = 'block';
				    	setTimeout(() => {  
				    	    dropdown.style.display = 'none';  
							flagmy.value =null
				    	}, 2000); 	
				case('用户信息修改失败!可能为用户名重复'):
				    dropdown.style.display = 'block';
				    	setTimeout(() => {  
				    	    dropdown.style.display = 'none';  
							flagmy.value =null
				    	}, 2000); 	
					
				} /* switch结束*/
				
				
              }/*showDropdown()结束*/ 
showDropdown()
